package juc.thread.secuity;
/*
* 测试不同方法加锁会不会
* */
public class Test5 {
    public static void main(String[] args) {
        Test test = new Test();
        new Thread(()->{
            test.m1();
        }).start();
        new Thread(()->{
            test.m2();
        }).start();
    }


    static class Test{
        public synchronized  void m1(){
            try {
                System.out.println("m1");
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        public synchronized  void m2(){
            System.out.println("m2");
        }
    }
}
